package charlie.demo.beetlsql.beetlsql_demo.controller;

import charlie.demo.beetlsql.beetlsql_demo.dao.AccountDao;
import charlie.demo.beetlsql.beetlsql_demo.pojo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.sql.DataSource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/")
public class AppController {

    @Autowired
    DataSource dataSource;

    @Autowired
    AccountDao accountDao;

    @RequestMapping("/accountList")
    public Object first(){

        List<Account> list = accountDao.selectAccountByName("aaa");
        Map<String, Object> param = new HashMap< >();
        param.put("list", list);

        return new ModelAndView( "/account/list.html", param);
    }
}
